package be.novelfaces.component.numpaddecsep;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;

import be.novelfaces.component.encoder.Encoder;

public class NumpadDecimalSeparatorRenderer extends Renderer {
	
	private Encoder jsEncoder = new NumpadDecimalSeparatorJSEncoder();
	
	@Override
	public void encodeBegin(FacesContext context, UIComponent component)
			throws IOException {
		ResponseWriter writer = context.getResponseWriter();
		writer.startElement("span", null);
		writer.writeAttribute("id", component.getClientId(), null);
	}
	
	@Override
	public void encodeEnd(FacesContext context, UIComponent component)
			throws IOException {
		ResponseWriter writer = context.getResponseWriter();
		jsEncoder.encode(context, component);
		writer.endElement("span");
	}
	
	@Override
	public boolean getRendersChildren() {
		return true;
	}
	
}
